# -*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt

import algorithms.logistic as logistic
import algorithms.linear as linear


if __name__ == "__main__":
	model=linear.Linear()
	data = np.loadtxt('linear_regression_data1.txt', delimiter=',')
	X=data.T[0].reshape(97,1)
	y=data.T[1].reshape(97,1)
	model.fit1(X,y)
	w=model.w
	print(w)
	xx = np.arange(5,23).reshape(18,1)
	yy1 = np.mat(np.hstack((xx,np.ones(18).reshape(18,1))))*w
	current=model.predict(xx[0])
	print("the x is {0} ,and predict y is {1}".format(xx[0],current))

	model.fit0(X,y)
	w=model.w
	print(w)
	yy2 = np.mat(np.hstack((xx,np.ones(18).reshape(18,1))))*w
	current=model.predict(xx[0])
	print("the x is {0} ,and predict y is {1}".format(xx[0],current))
	plt.scatter(X, y, s=30, c='r', marker='x', linewidths=1)
	plt.xlim(4,24)
	plt.plot(xx,yy1)
	plt.plot(xx,yy2)
	plt.show()